// #include "sharedresources.hpp"
#include "log.hpp"

int main()
{
    // 创建管道
    Init init;

    Log log;

    log.record=CLASSIFYFILE;

    //向管道中读取
    int fd = open(FIFO_FILE,O_RDONLY);
    if(fd < 0)
    {
        perror("open fifo fail");
        return errno;
    }

    log(Info,"fifo oepn success,errno code:%d,fifo fd:%d",errno,fd);

    while(1)
    {
        char readbuffer[SIZE];
        int n = read(fd,readbuffer,sizeof(readbuffer));
        if(n>0)
        {
            readbuffer[n]='\0';
            cout<<"receive know :"<<readbuffer<<endl;
        }
        else if(n==0)
        {
            return 0;
        }
    }

    //关闭管道
    //调用Init的析构函数
    close(fd);

    return 0;
}